//
//  StrategyTableViewCell.m
//  Community
//
//  Created by 刘春雷 on 2018/12/20.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "StrategyTableViewCell.h"
#import "UIImageView+WebCache.h"
#import <Masonry.h>
@interface StrategyTableViewCell()
@property (nonatomic,strong)UIImageView *headerImage;
@property (nonatomic,strong)UILabel *addressLabel;
@property (nonatomic,strong)UILabel *infoLabel;
@end

@implementation StrategyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self initUI];
    }
    return self;
}
- (void)initUI {
    self.headerImage = [[UIImageView alloc]init];
    [self addSubview:self.headerImage];
    [self.headerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
    
    self.addressLabel =[[UILabel alloc]init];
    [self addSubview:self.addressLabel];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.left.mas_equalTo(self.headerImage.mas_right).offset(10);
        make.size.mas_equalTo(CGSizeMake(100, 20));
    }];
    
    self.infoLabel = [[UILabel alloc]init];
    self.infoLabel.numberOfLines = 0;
    [self addSubview:self.infoLabel];
    [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.addressLabel.mas_bottom).offset(5);
        make.left.mas_equalTo(self.headerImage.mas_right).offset(10);
        make.size.mas_equalTo(CGSizeMake(255, 75));
    }];
}
- (void)setStrategyData:(FoundModel *)cellModel {
    self.addressLabel.text = cellModel.name;
    [self.headerImage sd_setImageWithURL:[NSURL URLWithString:cellModel.photo_url] placeholderImage:[UIImage imageNamed:@" "]];
    if (cellModel.descrip.length > 0) {
        self.infoLabel.text = cellModel.descrip;
    }else if (cellModel.travel_tip.length > 0){
        self.infoLabel.text = cellModel.travel_tip;
    }else{
        self.infoLabel.text = @"暂无介绍";
    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
